package ui.panel
{

	import flash.display.Bitmap;
	import flash.display.Sprite;

	import globals.ButtonType;
	import globals.Global;

	import ui.component.Button;
	import ui.component.Grid;
	import ui.component.Label;

	import util.ColorUtil;
	import util.UIUtil;

	public class WarriorPanelbak extends BasePanel
	{

		private var avatarName:Label;
		private var avatar:Bitmap;
		private var avatarLevel:Label;
		private var avatatExpbar:Sprite;
		private var avatarExplabel:Label;

		private var equipGrids:Array;
		private var speedLabel:Label;
		private var attackLabel:Label;
		private var rangeLabel:Label;

		private var levelupButton:Button;

		private var leftArrow:Button;
		private var rightArrow:Button;
		private var warriorList:Array;

		public function WarriorPanelbak()
		{
			super();
			pid = PanelType.WARRIOR_PANEL;
		}

		override protected function initUI():void
		{
			super.initUI();

			_title.text = "查看英雄";

			var bg:Bitmap;
//			bg = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("1"));
//			bg.x = 50;
//			bg.y = 300;
//			addChild(bg);
			avatarName = new Label(16, ColorUtil.FONT_BROWN, true, "center");
			avatarName.x = 80;
			avatarName.y = 80;
			addChild(avatarName);
			avatar = new Bitmap();
			addChild(avatar);
			bg = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("warrior_level_exp"));
			bg.x = 50;
			bg.y = 280;
			addChild(bg);
			avatarLevel = new Label(12, 0xFFFFFF);
			avatarLevel.x = 66;
			avatarLevel.y = 288;
			addChild(avatarLevel);
			avatarExplabel = new Label(12, 0xFFFFFF, false, "center");
			avatarExplabel.x = 92;
			avatarExplabel.y = 310;
			addChild(avatarExplabel);

			speedLabel = new Label(12, 0xFFFFFF, false, "left", true);
			speedLabel.x = 250;
			speedLabel.y = 200;
			addChild(speedLabel);
			attackLabel = new Label(12, 0xFFFFFF, false, "left", true);
			attackLabel.x = 350;
			attackLabel.y = 200;
			addChild(attackLabel);
			rangeLabel = new Label(12, 0xFFFFFF, false, "left", true);
			rangeLabel.x = 450;
			rangeLabel.y = 200;
			addChild(rangeLabel);

			levelupButton = UIUtil.getButton(0, ButtonType.BUTTON_GREEN_SMALL, levelupHandler);
			levelupButton.x = 350;
			levelupButton.y = 240;
			addChild(levelupButton);

			bg = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("warrior_list_bg"));
			bg.x = 5;
			bg.y = 355;
			addChild(bg);
			leftArrow = UIUtil.getButton(0, ButtonType.BUTTON_ARROW_LEFT, leftHandler);
			leftArrow.x = 20;
			leftArrow.y = 375;
			addChild(leftArrow);
			rightArrow = UIUtil.getButton(0, ButtonType.BUTTON_ARROW_RIGHT, rightHandler);
			rightArrow.x = 515;
			rightArrow.y = 375;
			addChild(rightArrow);
		}

		private function levelupHandler(button:Button):void
		{
			trace("click levelup");
		}

		private function leftHandler(button:Button):void
		{
			trace("click left");
		}

		private function rightHandler(button:Button):void
		{
			trace("click right");
		}

		public function update():void
		{
			var i:int;
			avatarName.text = "服部半藏";
			avatar.x = 50;
			avatar.y = 100;
			avatar.bitmapData = Global.assetsManager.getAssetsAsBitmapData("avatar_1_0", "warrior");
			avatarLevel.text = "11";
			avatarExplabel.text = "111 / 999";
			speedLabel.text = "速度：250+10";
			attackLabel.text = "攻击：250+10";
			rangeLabel.text = "范围：250+10";

			var grid:Grid;

			for(i = 0; i < 3; i++)
			{
				grid = new Grid("1001");
				grid.x = 260 + i * 90;
				grid.y = 85;
				addChild(grid);
			}

			var ava:Bitmap;

			for(i = 0; i < 6; i++)
			{
				ava = new Bitmap(Global.assetsManager.getAssetsAsBitmapData("avatar_1_1", "warrior"));
				ava.x = 65 + i * 76;
				ava.y = 330;
				addChild(ava);
			}
		}

		override public function open(center:Boolean = true):void
		{
			super.open(center);
			update();
		}
	}
}